You can create various Java code templates in Eclipse via the
Window->Preferences->Java -> Editor -> Templates
e.g.
sysout is expanded to:
System.out.println(${word_selection}${});${cursor}You can activate this by typing sysout followed by CTRL+SPACE
What useful Java code templates do you currently use?
Include the name and description of it and why it's awesome.
Anonymous User
17-Jul-2015${:import(org.apache.log4j.Logger)}private static final Logger LOGGER = Logger.getLogger(${enclosing_type}.class);
${:import(java.nio.file.Files,java.nio.file.Paths,
java.nio.charset.Charset,
java.io.IOException,
java.io.BufferedReader)}
try (BufferedReader in = Files.newBufferedReader(Paths.get(${fileName:var(String)}),
Charset.forName("UTF-8"))) {
String line = null;
while ((line = in.readLine()) != null) {
${cursor}
}
} catch (IOException e) {
// ${todo}: handle exception
}